package com.huike.controller.course;


import com.huike.dto.CourseDto;
import com.huike.entity.Course;
import com.huike.result.PageResult;
import com.huike.result.Result;
import com.huike.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/course")
public class CourseController {

    @Autowired
    private CourseService courseService;

    @GetMapping("/search")
    public Result<PageResult> queryPage(CourseDto courseDto){

        return courseService.queryPage(courseDto);
    }

    @PutMapping("/update")
    public Result update(@RequestBody Course course){
        return courseService.updateCourse(course);
    }

    @DeleteMapping("/delete")
    public Result deleteList(@RequestParam List<Integer> ids){
        return courseService.deleteList(ids);
    }

    @GetMapping("/find/{id}")
    public Result findById(@PathVariable Integer id){
        return courseService.findById(id);
    }

    @PostMapping("/add")
    public Result addCourse(@RequestBody Course course){
        return  courseService.addCourse(course);
    }

    @GetMapping("/subject")
    public Result subjectList(){
        return courseService.subjectList();
    }

    @GetMapping("/course")
    public Result courseList(){
        return courseService.courseList();
    }
    @GetMapping("/applicablePeople")
    public Result applicablePeopleList(){
        return courseService.applicablePeopleList();
    }


}
